from django.contrib import admin
from .models import GuitarTab, GuitarTabImage


class GuitarTabImageInline(admin.TabularInline):  # 定义内联模型
    model = GuitarTabImage
    extra = 1  # 额外的空白行数，用于添加新记录


@admin.register(GuitarTab)
class GuitarTabAdmin(admin.ModelAdmin):
    list_display = ('id', 'name', 'author', 'type', 'create_time')
    inlines = [GuitarTabImageInline]  # 正确引用内联模型类


@admin.register(GuitarTabImage)
class GuitarTabImageAdmin(admin.ModelAdmin):
    list_display = ('id', 'save_name', 'index', 'scroll_speed', 'rollback_to', 'rollback_times', 'guitar_tab')
